<div *ngIf="!hasImportedVideo" class="upload-video-container" dragDrop (fileDropped)="setTorrentFile($event)">
  <div class="first-step-block">
    <my-global-icon class="upload-icon" iconName="upload" aria-hidden="true"></my-global-icon>

    <div class="button-file form-control" [ngbTooltip]="'(extensions: .torrent)'">
      <span i18n>Select the torrent to import</span>
      <input
        aria-label="Select the torrent to import" i18n-aria-label
        #torrentfileInput type="file" name="torrentfile" id="torrentfile" accept=".torrent" (change)="fileChange()"
      />
    </div>

    <div class="torrent-or-magnet" i18n-data-content data-content="OR"></div>

    <div class="form-group form-group-magnet-uri">
      <label i18n for="magnetUri">Paste magnet URI</label>
      <my-help>
        <ng-template ptTemplate="customHtml">
          <ng-container i18n>
            You can import any torrent file that points to a media file.
            You should make sure you have diffusion rights over the content it points to, otherwise it could cause legal trouble to yourself and your instance.
          </ng-container>
        </ng-template>
      </my-help>

      <input type="text" id="magnetUri" [(ngModel)]="magnetUri" class="form-control" />
    </div>

    <div class="form-group">
      <label i18n for="first-step-channel">Channel</label>
      <my-select-channel
        labelForId="first-step-channel" [items]="userVideoChannels" [(ngModel)]="firstStepChannelId"
      ></my-select-channel>
    </div>

    <div class="form-group">
      <label i18n for="first-step-privacy">Privacy</label>
      <my-select-options
        labelForId="first-step-privacy" [items]="videoPrivacies" [(ngModel)]="firstStepPrivacyId"
      ></my-select-options>
    </div>

    <input
      type="button" i18n-value value="Import"
      [disabled]="!isMagnetUrlValid() || isImportingVideo" (click)="importVideo()"
    />
  </div>
</div>

<div *ngIf="error" class="alert alert-danger">
  <div i18n>Sorry, but something went wrong</div>
  {{ error }}
</div>

<div *ngIf="hasImportedVideo && !error" class="alert alert-info" i18n>
  Congratulations, the video will be imported with BitTorrent! You can already add information about this video.
</div>

<!-- Hidden because we want to load the component -->
<form [hidden]="!hasImportedVideo" novalidate [formGroup]="form">
  <my-video-edit
    [form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions" [schedulePublicationPossible]="false"
    [validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels"
    type="import-torrent"
  ></my-video-edit>

  <div class="submit-container">
    <div class="submit-button"
       (click)="updateSecondStep()"
       [ngClass]="{ disabled: !form.valid || isUpdatingVideo === true }"
    >
      <my-global-icon iconName="circle-tick" aria-hidden="true"></my-global-icon>
      <input type="button" i18n-value value="Update" />
    </div>
  </div>
</form>
